var e = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        tabsIndex: 0,
        seeTabIndex: 0,
        seeTabArray: [],
        liveRecordIndex: 0,
        liveRecordArray: [],
        releaseTabIndex: 0,
        releaseTabArray: [ {
            name: "广告审核"
        }, {
            name: "普通区"
        }, {
            name: "广告专区"
        } ],
        releaseExamineIndex: 0,
        releaseExamineArray: [ {
            name: "全部"
        }, {
            name: "待审核"
        }, {
            name: "审核通过"
        }, {
            name: "审核驳回"
        } ],
        releaseOrdinaryIndex: 0,
        releaseOrdinaryArray: [ {
            name: "全部",
            value: 0
        }, {
            name: "图文",
            value: 1
        }, {
            name: "视频",
            value: 4
        }, {
            name: "音频",
            value: 3
        }, {
            name: "文章",
            value: 2
        } ],
        screenShow: !1,
        details: {},
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1
    },
    onLoad: function(e) {
        this.getBehavior();
    },
    gotoPages: function(e) {
        var a = e.currentTarget.dataset.page;
        wx.navigateTo({
            url: a
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    cancelAttention: function(e) {
        var a = e.detail, t = this.data.listData;
        t.splice(a, 1), this.setData({
            listData: t
        });
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    setTabsIndex: function(a) {
        var t, n = a.currentTarget.dataset.index, i = a.currentTarget.dataset.name;
        n != this.data[i] && (this.setData((e(t = {}, i, n), e(t, "networkLoading", !1), 
        e(t, "screenShow", !1), t)), this.getListData());
    },
    setScreenShow: function() {
        this.setData({
            screenShow: !this.data.screenShow
        });
    },
    getBehavior: function(e) {
        var t = this, n = a.getNetAddresss("plugin.new-media-advertising.frontend.member.my-behavior");
        a._getNetWork({
            url: n,
            success: function(n) {
                var i = n.data;
                if (1 != i.result) return a.tips(i.msg);
                if (1 != e) {
                    var r = i.data.name_set, s = [ {
                        name: r.read_name + "记录",
                        value: 3
                    }, {
                        name: r.like_name + "记录",
                        value: 1
                    }, {
                        name: r.favorites_name + "记录",
                        value: 5
                    }, {
                        name: r.comment_name + "记录",
                        value: 6
                    }, {
                        name: r.share_name + "记录",
                        value: 4
                    }, {
                        name: r.attention_name + "记录",
                        value: 2
                    }, {
                        name: "直播",
                        value: "live"
                    } ], d = [ {
                        name: r.read_name + "记录",
                        value: 3
                    }, {
                        name: r.like_name + "记录",
                        value: 1
                    }, {
                        name: r.comment_name + "记录",
                        value: 6
                    }, {
                        name: r.share_name + "记录",
                        value: 4
                    }, {
                        name: r.attention_name + "记录",
                        value: 2
                    } ];
                    t.setData({
                        details: i.data,
                        seeTabArray: s,
                        liveRecordArray: d
                    }), t.getListData();
                } else t.setData({
                    "details.stream": i.data.stream
                });
            }
        });
    },
    initPage: function() {
        this.setData({
            listData: [],
            networkLoading: !1
        }), this.data.page = 1, this.data.total_page = 0, this.data.isLoadMore = !0;
    },
    getListData: function() {
        var e = this, t = this.data, n = t.tabsIndex, i = t.seeTabIndex, r = t.seeTabArray, s = t.liveRecordIndex, d = t.liveRecordArray, o = t.releaseTabIndex, l = t.releaseExamineIndex, g = t.releaseOrdinaryArray, m = t.releaseOrdinaryIndex;
        this.initPage();
        var v, u = {};
        0 == n ? "live" == r[i].value ? (v = a.getNetAddresss("plugin.new-media-advertising.frontend.member.get-my-behavior-room-list"), 
        u.behavior_type = d[s].value) : (v = a.getNetAddresss("plugin.new-media-advertising.frontend.member.get-my-behavior-list"), 
        u.behavior_type = r[i].value) : 1 == n && (v = a.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.get-advertisingt-list"), 
        u.advertisingt_type = o, 0 == o ? 0 != l && (u.check_type = l - 1) : 1 == o && 0 != m && (u.genre = g[m].value)), 
        a._getNetWork({
            url: v,
            data: u,
            success: function(t) {
                var n = t.data;
                if (1 != n.result) return a.tips(n.msg);
                e.setData({
                    isLoadMore: !0,
                    total_page: n.data.last_page,
                    listData: n.data.data,
                    networkLoading: !0
                }), e.data.total_page || (e.data.total_page = 0);
            }
        });
    },
    getMoreData: function() {
        var e = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page++;
            var t, n = {
                page: this.data.page
            }, i = this.data, r = i.tabsIndex, s = i.seeTabIndex, d = i.seeTabArray, o = i.liveRecordIndex, l = i.liveRecordArray, g = i.releaseTabIndex, m = i.releaseExamineIndex, v = i.releaseOrdinaryIndex;
            0 == r ? "live" == d[s].value ? (t = a.getNetAddresss("plugin.new-media-advertising.frontend.member.get-my-behavior-room-list"), 
            n.behavior_type = l[o].value) : (t = a.getNetAddresss("plugin.new-media-advertising.frontend.member.get-my-behavior-list"), 
            n.behavior_type = d[s].value) : 1 == r && (t = a.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.get-advertisingt-list"), 
            n.advertisingt_type = g, 0 == g ? 0 != m && (n.check_type = m - 1) : 1 == g && 0 != v && (n.genre = v)), 
            a._getNetWork({
                url: t,
                data: n,
                success: function(a) {
                    var t = a.data;
                    if (1 == t.result) {
                        e.data.isLoadMore = !0;
                        var n = t.data.data;
                        e.setData({
                            listData: e.data.listData.concat(n)
                        });
                    } else e.data.isLoadMore = !1, e.data.page--;
                }
            });
        }
    }
});